﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MontarServicoConsulta.aspx.cs" Inherits="NewTierra.Pages.MontarServicos.MontarServicoConsulta" %>

<!DOCTYPE html>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" tagprefix="ajaxToolkit"%>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor" TagPrefix="cc1" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    
      <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
      <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
      <script type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>

      <link href="~/Styles/EstiloGeral.css" rel="stylesheet" type="text/css" />

    <style type="text/css">
        #MServico
        {
            height: 585px;
            width: 1100px;
        }
        #MServico .MServicoFormEsq
        {
            width: 401px;
            float: left;
            height: 492px;
        }
        #MServico .MServicoFormDir
        {
            height: 457px;
            float: left;
            width: 603px;
            margin-left: 10px;
        }
        .MServicoFormularioCrud
        {
            height: 424px;
            padding: 5px;
            display:inline;
	        float: left;
	        position: relative;
            border:1px solid #E6E6E6;
	        background: #FAFAFA;
	        color: #666;
            margin-top: 0px;
            width: 375px;
        }
        .BotoesMServico
        {
            height: 59px;
        }
        .MServCadastro
        {
            height: 363px;
        }
        .FormTransporte
        {
            height: 37px;
        }
        .FormTransporte .FormTransporte_tipo
        {
            width: 140px;
            float: left;
        }
        .FormTransporte .FormTransporte_capacidade
        {
            width: 88px;
            float: left;
        }
        .FormTransporte .FormTransporte_capacidadeTotal
        {
            width: 80px;
            float: left;
        }
        #SetMServico
        {
            height: 474px;
        }
        .FromDatas
        {
            height: 49px;
        }
        .FromDatas .dataFrom
        {
            width: 129px;
            float: left;
        }
        .FromDatas .dataTo
        {
            width: 129px;
            float: left;
        }
        .taxas
        {
            width: 373px;
            height: 50px;
        }
        .taxas .porcentagens
        {
            width: 172px;
            float: left;
        }
        .taxas .comissao
        {
            width: 103px;
            float: left;
        }
        .FormTipoServico
        {
            height: 51px;
        }
        .FormTipoServico .FormTipoServico_categoria
        {
            height: 37px;
            float: left;
            width: 150px;
        }
        .FormTipoServico .FormTipoServico_tiposervico
        {
            height: 38px;
            float: left;
            width: 150px;
        }
        .FormMoeda_Obs
        {
            height: 57px;
        }
        .FormMoeda_Obs .FormMoeda_Obs_moeda
        {
            width: 82px;
            float: left;
        }
        .FormMoeda_Obs .FormMoeda_Obs_obs
        {
            width: 284px;
            float: left;
            height: 53px;
        }        
        .GridMServico
        {
            margin-top: 10px;
            padding: 10px;
            height: 319px;
            width: 544px;
        }
        .DatalistBody
        {
            height: 66px;
        }
        .DatalistBody .HeaderDataList
        {
            height: 29px;
            float: left;
            width: 610px;
        }
        .DatalistBody .BodyDatalist
        {
            height: 16px;
            float: left;
            width: 605px;
        }
        .GridMServico_Filtro
        {
            padding: 10px;
            height: 43px;
        }
    </style>

    <script type="text/javascript">

        jQuery(function ($) {
            $.datepicker.regional['pt-BR'] = {
                closeText: 'Fechar',
                prevText: '&#x3c;Anterior',
                nextText: 'Pr&oacute;ximo&#x3e;',
                currentText: 'Hoje',
                monthNames: ['Janeiro', 'Fevereiro', 'Mar&ccedil;o', 'Abril', 'Maio', 'Junho',
             'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
                monthNamesShort: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun',
             'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
                dayNames: ['Domingo', 'Segunda-feira', 'Ter&ccedil;a-feira', 'Quarta-feira', 'Quinta-feira', 'Sexta-feira', 'Sabado'],
                dayNamesShort: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sab'],
                dayNamesMin: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sab'],
                weekHeader: 'Sm',
                dateFormat: 'dd/mm/yy',
                firstDay: 0,
                isRTL: false,
                showMonthAfterYear: false,
                yearSuffix: ''
            };
            $.datepicker.setDefaults($.datepicker.regional['pt-BR']);
        });

        $(function () {
            $("#from").datepicker({
                defaultDate: "+1w",
                changeMonth: true,
                numberOfMonths: 1,
                onClose: function (selectedDate) {
                    $("#to").datepicker("option", "minDate", selectedDate);
                }
            });
            $("#to").datepicker({
                defaultDate: "+1w",
                changeMonth: true,
                numberOfMonths: 1,
                onClose: function (selectedDate) {
                    $("#from").datepicker("option", "maxDate", selectedDate);
                }
            });
            $.datepicker.formatDate('yyyy-mm-dd');

            $("#txtBulk").keyup(function () {
                var value = $(this).val();
            });

        });

        function ShowIcon() {
            var e = document.getElementById("processing");
            e.style.visibility = (e.style.visibility == 'visible') ? 'hidden' : 'visible';
        }

        function CallServerServico() {
            document.getElementById('<%= btnFiltroNomeSupplier.ClientID %>').click();
        }

        function CallServerSupplierGrid() {
            document.getElementById('<%= btnFiltroNomeSupplierGrid.ClientID %>').click();
         }

    </script>

</head>

<body>
    <form id="formulario" runat="server">

            <asp:ScriptManager ID="ScriptManager1" runat="server"/>

        <div id="MServico">
    
             <h2 class="titulo">Montar Serviço</h2>
            <hr />

            <div class="MServicoFormEsq">
                     <fieldset id="SetMServico">
                         <legend><h3 style="margin-bottom: 0px">Serviço</h3></legend>

                         <div class="MServicoFormularioCrud radius">                                 

                                <div class="MServCadastro">

                                        <asp:TextBox ID="txtCodServico"  runat="server" style="display: none;"/>

                                    <p class="paragrafo">
                                        <asp:Label ID="lblSupplierMServicoTXT" runat="server" Text="Supplier:"></asp:Label> <br />
                                        <asp:TextBox ID="txtSupplier" runat="server" placeholder="Informe o nome do supplier." Width="340px" MaxLength="50"></asp:TextBox>  
                                        <asp:RequiredFieldValidator ID="RqSupplier" runat="server" 
                                            ControlToValidate="txtSupplier" ErrorMessage="*" 
                                            Font-Size="Small" ToolTip="Campo requerido." ValidationGroup="Salvar">
                                        </asp:RequiredFieldValidator>                                                                              
                                       
                                         <ajaxToolkit:AutoCompleteExtender ServiceMethod="SearchSuppliers"
                                            MinimumPrefixLength="1" 
                                            CompletionInterval="100" 
                                            EnableCaching="False" 
                                            TargetControlID="txtSupplier" 
                                            ID="AutoCompleteExtenderSupplier" 
                                            runat="server" 
                                            OnClientItemSelected="CallServerServico"
                                            DelimiterCharacters="" 
                                            Enabled="True">
                                        </ajaxToolkit:AutoCompleteExtender>                 
                                                               
                                        <asp:Button ID="btnFiltroNomeSupplier" style = "display:none" runat="server" OnClick="LimpaLabel"/>
                                    </p>


                                    <div class="FormTransporte">

                                        <div class="FormTransporte_tipo">
                                            <asp:Label ID="lblTransporteMServicoTXT" runat="server" Text="Tipo Transporte:"></asp:Label><br />
                                            <asp:DropDownList ID="ddlTipoTransporte" runat="server">
                                            </asp:DropDownList>
                                        </div>
                                        <div class="FormTransporte_capacidade">
                                            <asp:Label ID="lblDeParaMServicoTXT" runat="server" Text="De-Para:"></asp:Label><br />
                                            <asp:TextBox ID="txtDe" runat="server" Text="" MaxLength="4" Width="20px" />
                                            <asp:TextBox ID="txtPara" runat="server" Text="" MaxLength="4" Width="20px" />
                                        </div>
                                        <div class="FormTransporte_capacidadeTotal">
                                            <asp:Label ID="lblCapTotalMServicoTXT" runat="server" Text="Capacidade:"></asp:Label><br />
                                            <asp:TextBox ID="txtCapTotal" runat="server" Text="" MaxLength="3" Width="40px" />
                                        </div>

                                    </div>

                                  <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                   <ContentTemplate>

                                     <p class="paragrafo">
                                        <asp:Label ID="lblBulkMServicoTXT" runat="server" Text="Bulk:"></asp:Label><br />
                                        <asp:TextBox ID="txtBulk" runat="server" Text="" MaxLength="10" Width="50px" AutoPostBack="True" OnTextChanged="txtBulk_TextChanged" />
                                        <asp:RequiredFieldValidator 
                                            ID="RqBulk" 
                                            runat="server" 
                                            ErrorMessage="*"
                                            ToolTip="Campo requerido." ControlToValidate="txtBulk"
                                            ValidationGroup="Salvar"></asp:RequiredFieldValidator>
                                        <asp:Label ID="lblErroBulk" runat="server" />

                                         &nbsp;<asp:Label ID="lblTotalTarifaTXT" runat="server" Text="Total:"></asp:Label>
                                         <asp:TextBox ID="txtBulkTotal" runat="server" Width="50px" 
                                            Enabled="False"></asp:TextBox>
                                     </p>

                                     <div class="taxas">

                                       <div class="porcentagens">
                                        <asp:Label ID="lblPorcetagemTarifaTXT" runat="server" Text="Taxas:"></asp:Label><br />
                                        <asp:TextBox ID="txtPorcentagemTaxa" runat="server" Width="50px" 
                                        AutoPostBack="True" OnTextChanged="txtPorcentagemTaxa_TextChanged">0</asp:TextBox>%&nbsp;&nbsp;&nbsp;
                                        <asp:TextBox ID="txtPorcentagemImposto" runat="server" Width="50px" 
                                        AutoPostBack="True" OnTextChanged="txtPorcentagemTaxa_TextChanged" >0</asp:TextBox>% 
                                       </div>

                                       <div class="comissao">
                                         <asp:Label ID="lblComissaoTXT" runat="server" Text="Comissão:"></asp:Label><br />
                                         <asp:TextBox ID="txtComissao" runat="server" Width="50px" AutoPostBack="True" Text="0" OnTextChanged="txtComissao_TextChanged" />%
                                       </div>

                                   </div>

                                  </ContentTemplate>
                                 </asp:UpdatePanel>

                                    <div class="FromDatas">
                                        
                                        <div class="dataFrom">
                                            <asp:Label ID="lblFrom" runat="server" Text="Data From:"></asp:Label> <br />
                                            <asp:TextBox ID="from" runat="server" Width="100px" MaxLength="10" onkeypress="teste()"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="RqDataFrom" runat="server" 
                                            ControlToValidate="from" ErrorMessage="*" 
                                            Font-Size="Small" ToolTip="Campo requerido." ValidationGroup="Salvar">*</asp:RequiredFieldValidator>
                                        </div>

                                        <div class="dataTo">
                                            <asp:Label ID="lblTo" runat="server" Text="Data To:"></asp:Label><br />
                                            <asp:TextBox ID="to" runat="server" Width="100px" MaxLength="10"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="RqDataTo" runat="server" 
                                            ControlToValidate="to" ErrorMessage="*" Font-Size="Small" 
                                            ToolTip="Campo requerido." ValidationGroup="Salvar">*</asp:RequiredFieldValidator>
                                        </div>

                                    </div>

                                    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                      <ContentTemplate>

                                     <div class="FormTipoServico">
                                        
                                         <div class="FormTipoServico_tiposervico">
                                            <asp:Label ID="lblTipoServicoMServicoTXT" runat="server" Text="Tipo Serviço:"></asp:Label><br />
                                            <asp:DropDownList ID="ddlTipoServico" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlTipoServico_SelectedIndexChanged">
                                            </asp:DropDownList>
                                        </div>

                                        <div class="FormTipoServico_categoria">
                                            <asp:Label ID="lblTipoServicoCategMServicoTXT" runat="server" Text="Tipo Serviço Categoria:"></asp:Label><br />
                                            <asp:DropDownList ID="ddlTipoServicoCateg" runat="server">
                                            </asp:DropDownList>
                                        </div>

                                     </div>

                                      </ContentTemplate>
                                    </asp:UpdatePanel>

                                     <div class="FormMoeda_Obs">

                                        <div class="FormMoeda_Obs_moeda">
                                            <asp:Label ID="lblMoedaMServicoTXT" runat="server" Text="Moeda:"></asp:Label><br />
                                            <asp:DropDownList ID="ddlMoeda" runat="server">
                                            </asp:DropDownList>
                                        </div>

                                       <div class="FormMoeda_Obs_obs">
                                           <asp:Label ID="lblObsMServicoTXT" runat="server" Text="Observação:"></asp:Label><br />
                                           <asp:TextBox ID="txtObs" runat="server" TextMode="MultiLine" MaxLength="100" Width="272px" />
                                       </div>

                                     </div>

                                </div>

                                 <div class="BotoesMServico"> 
                                     <asp:Button ID="btnNovoMServico" runat="server" Text="Salvar" CssClass="btnsGeral" OnClick="SalvarMontarServico"  ValidationGroup="Salvar"  />
                                     <asp:Button ID="btnAtualizarMServico" runat="server" CssClass="btnsGeral" Text="Atualizar" OnClick="AtualizarMontarServico" ValidationGroup="Salvar"  />
                                     <asp:Button ID="btnExcluirMServico" runat="server" CssClass="btnsGeral" Text="Excluir" OnClick="DeleteMontarServico" OnClientClick="return confirm('Excluindo esse serviço, todos as fotos e infos do mesmo também serão excluídas. Confirma?');" />
                                     <asp:Button ID="btnLimparMServico" runat="server" CssClass="btnsGeral" Text="Limpar" OnClick="Limpar" /> <br />
                                     <asp:Label ID="lblMsgCadMServicos" runat="server" Font-Bold="True"></asp:Label>
                               </div>  

                             </div>



                         </fieldset>
            </div>

            <div class="MServicoFormDir">

               <fieldset style="margin-top: 2px">
                   <legend>Serviços por supplier</legend>

            <div class="GridMServico_Filtro">

                     <asp:Label ID="lblSupplierFiltroGrid" runat="server" Text="Supplier:"></asp:Label> <br />
                     <asp:TextBox ID="txtSupplierFiltroGrid" runat="server" placeholder="Informe o nome do supplier." Width="340px" MaxLength="50"></asp:TextBox> 
                     <ajaxToolkit:AutoCompleteExtender 
                        ServiceMethod="SearchSuppliers"
                        MinimumPrefixLength="1" 
                        CompletionInterval="100" 
                        EnableCaching="False" 
                        TargetControlID="txtSupplierFiltroGrid" 
                        ID="AutoCompleteSupplierGrid" 
                        runat="server" 
                        OnClientItemSelected="CallServerSupplierGrid"
                        DelimiterCharacters="" 
                        Enabled="True">
                      </ajaxToolkit:AutoCompleteExtender>                 
                                                               
                      <asp:Button ID="btnFiltroNomeSupplierGrid" style = "display:none" runat="server" OnClick="MontaGridPorSupplier"/>

            </div>

                <div class="GridMServico">               

                 <asp:GridView ID="GridMServico" runat="server" AutoGenerateColumns="false" Height="16px" Width="410px"
                     GridLines="None" CssClass="mGrid" PagerStyle-CssClass="pgr"
                     AlternatingRowStyle-CssClass="alt">

                     <AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>

                     <Columns>

                        <asp:BoundField DataField="S_Servicos_Tipo.Tipo_Nome" HeaderText="Tipo" 
                     SortExpression="S_Servicos_Tipo.Tipo_Nome"/>  

                         <asp:BoundField DataField="Tipo_Transporte.TipoTrans_nome" HeaderText="Transporte" 
                     SortExpression="Tipo_Transporte.TipoTrans_nome"/>  

                         <asp:BoundField DataField="S_Servicos_Tipo_Categ.Tipo_categ_nome" HeaderText="Categoria" 
                     SortExpression="S_Servicos_Tipo_Categ.Tipo_categ_nome"/>                         

                         <asp:BoundField DataField="MServico_Bulk_Total" HeaderText="$" 
                     SortExpression="MServico_Bulk_Total"/>  

                          <asp:BoundField DataField="MServico_CapMaxima" HeaderText="Até" 
                     SortExpression="MServico_CapMaxima"/>  
                         
                     </Columns>

                     <PagerStyle CssClass="pgr"></PagerStyle>

                 </asp:GridView>     
                    
                </div>
               </fieldset>

            </div>

    
    </div>
    </form>
</body>
</html>
